﻿@{
    ViewBag.Title = "明细管理";
}

@* Razor MVC单页面仅支持一个model *@
@model Work3.Models.assets

<div class="jumbotron">
    <h1>明细管理</h1>
    <div class="panel panel-default">
        <div class="panel-heading">
            <h3 class="panel-title">
                个人资产明细
            </h3>
        </div>
        @using (Html.BeginForm("showMine", "admin"))
        {
            <div style="text-align: center">
                <input class="btn btn-primary" type="submit" value="仅看自己"/>
                @* 使用onclick更改action从而访问不同后端接口 *@
                <input class="btn btn-primary col-sm-offset-1" type="submit" value="查看全部" 
                       onclick="this.form.action='admin/showAll'"/>
                <input class="btn btn-primary col-sm-offset-1" type="submit" value="插入新资产" 
                       onclick="this.form.action='admin/insertNewAssets'"/>
                <input class="btn btn-primary col-sm-offset-1" type="submit" value="仅查看明细" 
                       onclick="this.form.action='admin/showNormal'"/>
                <input class="btn btn-primary col-sm-offset-1" type="submit" value="查看类别" 
                                   onclick="this.form.action='admin/showDetail'"/>
            </div>
            
        }
        <div class="panel-body">
            <table class="table table-striped" style="table-layout: fixed">
                <thead>
                <tr>
                    <th>所有者</th>
                    <th>资产名称</th>
                    <th>数量</th>
                    <th>单位</th>
                    <th>操作</th>
                </tr>
                </thead>
                <tbody>
                @foreach (dynamic item in ViewBag.assetss) {
                    using (Html.BeginForm("Updateassets", "admin")) {
                        <tr>
                            <td hidden="hidden">
                                @Html.TextBoxFor(model => model.Id, new { @class = "form-control", Value = item.Id , @readonly = true})
                            </td>
                            <td style="width: 95%">
                                @Html.TextBoxFor(model => model.Owner,new {@class = "form-control", Value = item.Owner, @readonly = true})
                            </td>
                            <td style="width: 95%">
                                @Html.TextBoxFor(model => model.name, new {@class = "form-control", Value = item.name, @readonly = true})
                            </td>
                            <td style="width: 95%">
                                @Html.TextBoxFor(model => model.Num, new {@class = "form-control", Value = item.Num})
                            </td>
                            <td style="width: 110%">
                                @Html.TextBoxFor(model => model.Unit, new { @class = "form-control", Value = item.Unit, @readonly = true })
                            </td>
                            <td>
                                <div class="btn-group btn-group-sm">
                                    <input class="btn btn-primary" type="submit" value="修改"/>
                                    @* 使用onclick更改action从而访问不同后端接口 *@
                                    <input class="btn btn-primary col-sm-offset-1" type="submit" value="删除" 
                                           onclick="this.form.action='admin/Deleteassets'"/>
                                    <input class="btn btn-primary col-sm-offset-1" type="submit" value="类别" 
                                           onclick="this.form.action='admin/Deleteassets'"/>
                                </div>
                            </td>
                        </tr>
                    }
                }
                @using (Html.BeginForm("addNew", "admin"))
                {
                    if (ViewBag.Insert != 0)
                    {
                        <tr>
                            <td hidden="hidden">
                                @Html.TextBoxFor(model => model.Id, new { @class = "form-control", Value = ViewBag._max + 1 , @readonly = true})
                            </td>
                            <td>
                                @Html.TextBoxFor(model => model.Owner, new { @class = "form-control", Value = "" })
                            </td>
                            <td>
                                @Html.TextBoxFor(model => model.name, new { @class = "form-control", Value = "" })
                            </td>
                            <td>
                                @Html.TextBoxFor(model => model.Num, new { @class = "form-control", Value = "" })
                            </td>
                            <td>
                                @Html.TextBoxFor(model => model.Unit, new { @class = "form-control", Value = "" })
                            </td>
                            <td>
                                <div class="btn-group btn-group-sm">
                                    <input class="btn btn-primary col-sm-offset-1" type="submit" value="插入"/>
                                </div>
                            </td>
                        </tr>
                    }
                }
                </tbody>
            </table>
            @if (ViewBag.show != 0)
            {
                <table class="table table-striped" style="table-layout: fixed">
                    <thead>
                    <tr>
                        <th>资产名称</th>
                        <th>资产类别</th>
                    </tr>
                    </thead>
                    <tbody>
                    @foreach (dynamic item in ViewBag.res) {
                            <tr>
                                <td>
                                    @item.Name
                                </td>
                                <td>
                                    @item.Type
                                </td>
                            </tr>
                    }
                    </tbody>
                </table>
            }
            else
            {
            }
        </div>
    </div>
</div>